{extend name="public/base" /}

{block name="content"}
<!--页面路径 和 页面标题-->
<div class="page-title">

    <div class="title-env">
        <h1 class="title">专家管理</h1>
        <p class="description">所有专家</p>
    </div>

    <div class="breadcrumb-env">

        <ol class="breadcrumb bc-1">
            <li>
                <a href="/admin"><i class="fa-home"></i>Home</a>
            </li>
            <li class="active">
                <strong>专家列表</strong>
            </li>
        </ol>

    </div>

</div>

<div class="row">
    <div class="col-md-12">

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">专家列表</font></font></h3>
                <div class="panel-options">
                    <a class="btn btn-icon btn-info pull-right" href="/admin/expert/add" style="color: white;margin-left: 0.8rem">
                        <i class="fa-plus"></i> 添加专家
                    </a>
                    <button class="btn btn-icon btn-success pull-right" data-toggle="modal" data-target="#search-model">
                        <i class="fa-search"></i> 搜索
                    </button>
                </div>
            </div>

            <div class="panel-body panel-border">

                <div class="row">

                    <div class="col-sm-12">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>封面</th>
                                <th>头像</th>
                                <th style="width: 10%">名字</th>
                                <th>简介</th>
                                <th>状态</th>
                                <th style="width: 15%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $lists as $key => $list}
                            <tr>
                                <td>{$key+1}</td>
                                <td>
                                    <img src="{$list.cover_image}" width="80px">
                                </td>
                                <td>
                                    <img src="{$list.avatar}" width="80px" height="80px" style="border-radius: 50%">
                                </td>
                                <td>{$list.name}</td>
                                <td>
                                    <p class="yichu">{$list.desc}</p>
                                </td>
                                <td>
                                    <p class="text-left">发布：
                                        <input type="checkbox" onclick="change_status({$list.id},'is_show')" {if condition="$list.is_show == 1"}checked=""{/if}  class="iswitch iswitch-info">
                                    </p>
                                </td>
                                <td>
                                    <a class="btn btn-icon btn-success" href="/admin/expert/edit/id/{$list.id}">
                                        <i class="fa-edit"></i>
                                    </a>

                                    <button class="btn btn-icon btn-red" onclick="deleted({$list.id},'expert')">
                                        <i class="fa-trash"></i>
                                    </button>
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <label class="col-md-6 control-label">共 {$total} 条记录</label>
                    <div class="col-md-6 text-right">
                        <nav aria-label="Page navigation">
                            {$page}
                        </nav>
                    </div>
                </div>
            </div>

        </div>

    </div>
</div>
{/block}

{block name="modal"}
<!--搜索模态框-->
<div class="modal fade" id="search-model" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <form method="get" class="form-horizontal" action="/admin/expert/index">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">数据搜索</h4>
                </div>

                <div class="modal-body">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">专家名</label>
                            <div class="col-sm-6">
                                <input type="text" name="name" class="form-control" size="25" placeholder="专家名" value="{$Think.get.name}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-6">
                                <select name="is_show" class="form-control">
                                    <option value="0"></option>
                                    <option value="1" {if condition="$Think.get.is_show == 1"}selected{/if}>发布</option>
                                    <option value="2" {if condition="$Think.get.is_show == 2"}selected{/if}>隐藏</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <input type="submit" class="btn btn-info" value="确定搜索">
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="js"}


<script>
    //删除视频
    function deleted(id,type) {
        if(confirm("是否确认删除")){
            $.ajax({
                url:'/admin/expert/deleted',
                method: 'POST',
                dataType: 'json',
                data:{
                    id:id,
                    type:type
                },
                success: function(res)
                {
                    if(res.code == 0) {
                        success(res.message);
                        setTimeout("location.reload()",1000);
                    }else{
                        error(res.mssage);
                    }
                }
            })
        }
    };

    function change_status(id,field) {
        $.ajax({
            url:'/admin/expert/changeStatus',
            method: 'POST',
            dataType: 'json',
            data:{
                id:id,
                type:'expert',
                field:field
            },
            success: function(res)
            {
                if(res.code != 0) {
                    error(res.message);
                }
            }
        })
    };
</script>
{/block}